{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Callgraph Magic Examples"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This notebook shows examples of the [callgraph](https://github.com/osteele/callgraph) IPython extension. You can also use `?callgraph` in Jupyter to see documentation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Installation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Load the extension:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "%load_ext callgraph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This depends on the callgraph package having been installed, via `pip install callgraph` or otherwise.\n",
    "\n",
    "See the package documentation for an alternative to including `%load_ext callgraph` in each notebook that uses `%callgraph`.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"203pt\" viewBox=\"0.00 0.00 576.00 203.11\" width=\"576pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(.7597 .7597) rotate(0) translate(4 263.365)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-263.365 754.2038,-263.365 754.2038,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- 3 -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>3</title>\n",
       "<ellipse cx=\"87.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"87.1019\" y=\"-90.9408\">nchoosek(2, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>2</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-164.7821\">nchoosek(3, 1) ↦ 3</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;3 -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>2-&gt;3</title>\n",
       "<path d=\"M236.0133,-150.0317C207.4804,-139.0583 169.8788,-124.597 139.5995,-112.9519\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"140.6365,-109.6009 130.0466,-109.278 138.1238,-116.1344 140.6365,-109.6009\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>4</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-90.9408\">nchoosek(2, 1) ↦ 2</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;4 -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>2-&gt;4</title>\n",
       "<path d=\"M279.1019,-147.5872C279.1019,-139.7493 279.1019,-130.4909 279.1019,-121.8357\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"282.602,-121.7134 279.1019,-111.7134 275.602,-121.7134 282.602,-121.7134\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 5 -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>5</title>\n",
       "<ellipse cx=\"87.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"87.1019\" y=\"-17.0995\">nchoosek(1, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- 4&#45;&gt;5 -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>4-&gt;5</title>\n",
       "<path d=\"M236.0133,-76.1905C207.4804,-65.217 169.8788,-50.7558 139.5995,-39.1107\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"140.6365,-35.7596 130.0466,-35.4367 138.1238,-42.2931 140.6365,-35.7596\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 6 -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>6</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-17.0995\">nchoosek(1, 1) ↦ 1</text>\n",
       "</g>\n",
       "<!-- 4&#45;&gt;6 -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>4-&gt;6</title>\n",
       "<path d=\"M279.1019,-73.7459C279.1019,-65.908 279.1019,-56.6496 279.1019,-47.9944\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"282.602,-47.8721 279.1019,-37.8721 275.602,-47.8722 282.602,-47.8721\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>1</title>\n",
       "<ellipse cx=\"375.1019\" cy=\"-240.4444\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"375.1019\" y=\"-238.6233\">nchoosek(4, 2) ↦ 6</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>1-&gt;2</title>\n",
       "<path d=\"M351.3715,-222.1915C339.1406,-212.7837 324.0567,-201.1815 310.8387,-191.0145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"312.9523,-188.2246 302.8919,-184.902 308.6845,-193.7731 312.9523,-188.2246\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 7 -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>7</title>\n",
       "<ellipse cx=\"471.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"471.1019\" y=\"-164.7821\">nchoosek(3, 2) ↦ 3</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;7 -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>1-&gt;7</title>\n",
       "<path d=\"M398.8322,-222.1915C411.0631,-212.7837 426.1471,-201.1815 439.3651,-191.0145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"441.5193,-193.7731 447.3118,-184.902 437.2515,-188.2246 441.5193,-193.7731\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 9 -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>9</title>\n",
       "<ellipse cx=\"471.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"471.1019\" y=\"-17.0995\">nchoosek(1, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- 8 -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>8</title>\n",
       "<ellipse cx=\"471.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"471.1019\" y=\"-90.9408\">nchoosek(2, 1) ↦ 2</text>\n",
       "</g>\n",
       "<!-- 8&#45;&gt;9 -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>8-&gt;9</title>\n",
       "<path d=\"M471.1019,-73.7459C471.1019,-65.908 471.1019,-56.6496 471.1019,-47.9944\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"474.602,-47.8721 471.1019,-37.8721 467.602,-47.8722 474.602,-47.8721\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 10 -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>10</title>\n",
       "<ellipse cx=\"663.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"663.1019\" y=\"-17.0995\">nchoosek(1, 1) ↦ 1</text>\n",
       "</g>\n",
       "<!-- 8&#45;&gt;10 -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>8-&gt;10</title>\n",
       "<path d=\"M514.1904,-76.1905C542.7233,-65.217 580.325,-50.7558 610.6043,-39.1107\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"612.08,-42.2931 620.1571,-35.4367 609.5672,-35.7596 612.08,-42.2931\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 7&#45;&gt;8 -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>7-&gt;8</title>\n",
       "<path d=\"M471.1019,-147.5872C471.1019,-139.7493 471.1019,-130.4909 471.1019,-121.8357\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"474.602,-121.7134 471.1019,-111.7134 467.602,-121.7134 474.602,-121.7134\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 11 -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>11</title>\n",
       "<ellipse cx=\"663.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"663.1019\" y=\"-90.9408\">nchoosek(2, 2) ↦ 1</text>\n",
       "</g>\n",
       "<!-- 7&#45;&gt;11 -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>7-&gt;11</title>\n",
       "<path d=\"M514.1904,-150.0317C542.7233,-139.0583 580.325,-124.597 610.6043,-112.9519\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"612.08,-116.1344 620.1571,-109.278 609.5672,-109.6009 612.08,-116.1344\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def nchoosek(n, k):\n",
    "    if k == 0:\n",
    "        return 1\n",
    "    if n == k:\n",
    "        return 1\n",
    "    return nchoosek(n - 1, k - 1) + nchoosek(n - 1, k)\n",
    "\n",
    "%callgraph -w8 nchoosek(4, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[`lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache) caches (“[memoizes](https://en.wikipedia.org/wiki/Memoization)”) calls to `nchoosek`. Contrast the call graph above, where `nchoosek(1, 0)` , `nchoosek(1, 1)` , and `nchoosek(2, 1)` are each executed twice, to the following:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"267pt\" viewBox=\"0.00 0.00 566.20 267.37\" width=\"566pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 263.365)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-263.365 562.2038,-263.365 562.2038,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- nchoosek(2, 0){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>nchoosek(2, 0){}</title>\n",
       "<ellipse cx=\"87.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"87.1019\" y=\"-90.9408\">nchoosek(2, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>nchoosek(3, 1){}</title>\n",
       "<ellipse cx=\"183.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.1019\" y=\"-164.7821\">nchoosek(3, 1) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 0){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 0){}</title>\n",
       "<path d=\"M159.3715,-148.3503C147.1406,-138.9425 132.0567,-127.3402 118.8387,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"120.9523,-114.3834 110.8919,-111.0607 116.6845,-119.9319 120.9523,-114.3834\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>nchoosek(2, 1){}</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-90.9408\">nchoosek(2, 1) ↦ 2</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M206.8322,-148.3503C219.0631,-138.9425 234.1471,-127.3402 247.3651,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"249.5193,-119.9319 255.3118,-111.0607 245.2515,-114.3834 249.5193,-119.9319\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 0){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>nchoosek(1, 0){}</title>\n",
       "<ellipse cx=\"183.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.1019\" y=\"-17.0995\">nchoosek(1, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 0){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 0){}</title>\n",
       "<path d=\"M255.3715,-74.509C243.1406,-65.1012 228.0567,-53.499 214.8387,-43.332\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"216.9523,-40.5421 206.8919,-37.2195 212.6845,-46.0906 216.9523,-40.5421\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 1){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>nchoosek(1, 1){}</title>\n",
       "<ellipse cx=\"375.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"375.1019\" y=\"-17.0995\">nchoosek(1, 1) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 1){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 1){}</title>\n",
       "<path d=\"M302.8322,-74.509C315.0631,-65.1012 330.1471,-53.499 343.3651,-43.332\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"345.5193,-46.0906 351.3118,-37.2195 341.2515,-40.5421 345.5193,-46.0906\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>nchoosek(4, 2){}</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-240.4444\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-238.6233\">nchoosek(4, 2) ↦ 6</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 1){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 1){}</title>\n",
       "<path d=\"M255.3715,-222.1915C243.1406,-212.7837 228.0567,-201.1815 214.8387,-191.0145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"216.9523,-188.2246 206.8919,-184.902 212.6845,-193.7731 216.9523,-188.2246\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>nchoosek(3, 2){}</title>\n",
       "<ellipse cx=\"375.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"375.1019\" y=\"-164.7821\">nchoosek(3, 2) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 2){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 2){}</title>\n",
       "<path d=\"M302.8322,-222.1915C315.0631,-212.7837 330.1471,-201.1815 343.3651,-191.0145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"345.5193,-193.7731 351.3118,-184.902 341.2515,-188.2246 345.5193,-193.7731\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M351.3715,-148.3503C339.1406,-138.9425 324.0567,-127.3402 310.8387,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"312.9523,-114.3834 302.8919,-111.0607 308.6845,-119.9319 312.9523,-114.3834\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 2){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>nchoosek(2, 2){}</title>\n",
       "<ellipse cx=\"471.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"471.1019\" y=\"-90.9408\">nchoosek(2, 2) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 2){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 2){}</title>\n",
       "<path d=\"M398.8322,-148.3503C411.0631,-138.9425 426.1471,-127.3402 439.3651,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"441.5193,-119.9319 447.3118,-111.0607 437.2515,-114.3834 441.5193,-119.9319\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from functools import lru_cache\n",
    "\n",
    "@lru_cache()\n",
    "def nchoosek(n, k):\n",
    "    if k == 0:\n",
    "        return 1\n",
    "    if n == k:\n",
    "        return 1\n",
    "    return nchoosek(n - 1, k - 1) + nchoosek(n - 1, k)\n",
    "\n",
    "%callgraph -w8 nchoosek(4, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's another recursive function. The [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance), or “edit distance”, counts the number of additions, removals, and single-character changes to transform one string into another."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"415pt\" viewBox=\"0.00 0.00 754.63 415.05\" width=\"755pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 411.0476)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-411.0476 750.6335,-411.0476 750.6335,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- lev(&#39;&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>lev('', ''){}</title>\n",
       "<ellipse cx=\"374.6919\" cy=\"-18.9206\" fill=\"none\" rx=\"59.0841\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"374.6919\" y=\"-17.0995\">lev('', '') ↦ 0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>lev('g', 'g'){}</title>\n",
       "<ellipse cx=\"374.6919\" cy=\"-92.7619\" fill=\"none\" rx=\"68.8831\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"374.6919\" y=\"-90.9408\">lev('g', 'g') ↦ 0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('', ''){}</title>\n",
       "<path d=\"M374.6919,-73.7459C374.6919,-65.908 374.6919,-56.6496 374.6919,-47.9944\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"378.192,-47.8721 374.6919,-37.8721 371.192,-47.8722 378.192,-47.8721\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>lev('g', ''){}</title>\n",
       "<ellipse cx=\"233.6919\" cy=\"-18.9206\" fill=\"none\" rx=\"63.9836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"233.6919\" y=\"-17.0995\">lev('g', '') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('g', ''){}</title>\n",
       "<path d=\"M342.3437,-75.8212C322.1395,-65.2403 295.9529,-51.5265 274.3504,-40.2134\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"275.8862,-37.0668 265.4037,-35.528 272.6387,-43.2679 275.8862,-37.0668\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>lev('', 'g'){}</title>\n",
       "<ellipse cx=\"515.6919\" cy=\"-18.9206\" fill=\"none\" rx=\"63.9836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"515.6919\" y=\"-17.0995\">lev('', 'g') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('', 'g'){}</title>\n",
       "<path d=\"M407.0402,-75.8212C427.2444,-65.2403 453.431,-51.5265 475.0334,-40.2134\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"476.7452,-43.2679 483.9801,-35.528 473.4976,-37.0668 476.7452,-43.2679\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>lev('ig', 'og'){}</title>\n",
       "<ellipse cx=\"376.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"76.7836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"376.6919\" y=\"-238.6233\">lev('ig', 'og') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M376.4346,-221.4398C376.0925,-196.1844 375.485,-151.3224 375.0853,-121.8081\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"378.5835,-121.6452 374.9483,-111.6935 371.5841,-121.74 378.5835,-121.6452\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>lev('ig', 'g'){}</title>\n",
       "<ellipse cx=\"271.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"71.8844\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"271.6919\" y=\"-164.7821\">lev('ig', 'g') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M351.2744,-222.5695C337.5757,-212.9359 320.4894,-200.92 305.6642,-190.4942\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"307.4326,-187.4589 297.2394,-184.5694 303.4058,-193.1848 307.4326,-187.4589\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>lev('g', 'og'){}</title>\n",
       "<ellipse cx=\"476.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"73.7827\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"476.6919\" y=\"-164.7821\">lev('g', 'og') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge12\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M401.1547,-222.3808C414.0833,-212.8341 430.1258,-200.9882 444.0968,-190.6718\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"446.5163,-193.2361 452.4817,-184.4803 442.3581,-187.6049 446.5163,-193.2361\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M296.6254,-148.7282C310.1627,-139.0233 327.0725,-126.9006 341.6895,-116.4215\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"343.9001,-119.1432 349.9881,-110.4722 339.8216,-113.4542 343.9001,-119.1432\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('g', ''){}</title>\n",
       "<path d=\"M267.5038,-147.7012C263.2703,-128.9068 256.4109,-99.2855 249.6919,-73.8413 247.4386,-65.3082 244.8217,-56.0812 242.365,-47.6704\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"245.6735,-46.5157 239.4833,-37.9173 238.9604,-48.4992 245.6735,-46.5157\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>lev('ig', ''){}</title>\n",
       "<ellipse cx=\"173.6919\" cy=\"-92.7619\" fill=\"none\" rx=\"66.9852\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"173.6919\" y=\"-90.9408\">lev('ig', '') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M247.9689,-148.7282C235.2091,-139.114 219.3002,-127.1269 205.4827,-116.7157\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"207.2894,-113.6947 197.1965,-110.4722 203.0769,-119.2853 207.2894,-113.6947\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M452.0006,-148.7282C438.5947,-139.0233 421.8491,-126.9006 407.3739,-116.4215\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"409.3085,-113.5012 399.1559,-110.4722 405.2037,-119.1713 409.3085,-113.5012\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('', 'g'){}</title>\n",
       "<path d=\"M481.7107,-147.5986C488.4094,-122.2324 500.3313,-77.0873 508.1237,-47.5794\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"511.5231,-48.4145 510.6925,-37.8523 504.7551,-46.6271 511.5231,-48.4145\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>lev('', 'og'){}</title>\n",
       "<ellipse cx=\"677.6919\" cy=\"-92.7619\" fill=\"none\" rx=\"68.8831\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"677.6919\" y=\"-90.9408\">lev('', 'og') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge11\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('', 'og'){}</title>\n",
       "<path d=\"M519.3189,-150.9433C550.6793,-139.4225 593.4445,-123.7118 626.6313,-111.52\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"627.9792,-114.7536 636.1589,-108.0199 625.5653,-108.183 627.9792,-114.7536\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>lev('big', 'dog'){}</title>\n",
       "<ellipse cx=\"376.6919\" cy=\"-388.1269\" fill=\"none\" rx=\"86.5824\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"376.6919\" y=\"-386.3058\">lev('big', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge13\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M376.6919,-369.1224C376.6919,-343.867 376.6919,-299.005 376.6919,-269.4906\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"380.192,-269.376 376.6919,-259.376 373.192,-269.3761 380.192,-269.376\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>lev('big', 'og'){}</title>\n",
       "<ellipse cx=\"266.6919\" cy=\"-314.2857\" fill=\"none\" rx=\"81.6829\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"266.6919\" y=\"-312.4646\">lev('big', 'og') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge20\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('big', 'og'){}</title>\n",
       "<path d=\"M349.7829,-370.0633C335.4004,-360.4086 317.5147,-348.4022 302.0255,-338.0045\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"303.9579,-335.0863 293.7044,-332.4187 300.0564,-340.8983 303.9579,-335.0863\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node14\">\n",
       "<title>lev('ig', 'dog'){}</title>\n",
       "<ellipse cx=\"486.6919\" cy=\"-314.2857\" fill=\"none\" rx=\"81.6829\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"486.6919\" y=\"-312.4646\">lev('ig', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge27\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('ig', 'dog'){}</title>\n",
       "<path d=\"M403.601,-370.0633C417.9835,-360.4086 435.8692,-348.4022 451.3584,-338.0045\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"453.3274,-340.8983 459.6795,-332.4187 449.4259,-335.0863 453.3274,-340.8983\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge19\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M293.601,-296.2221C308.0908,-286.4953 326.1363,-274.3816 341.7048,-263.9308\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"343.7087,-266.8011 350.0607,-258.3215 339.8072,-260.9891 343.7087,-266.8011\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge14\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M267.3354,-295.2811C268.1904,-270.0257 269.7093,-225.1637 270.7085,-195.6494\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"274.2105,-195.6475 271.051,-185.5348 267.2145,-195.4106 274.2105,-195.6475\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node12\">\n",
       "<title>lev('big', 'g'){}</title>\n",
       "<ellipse cx=\"166.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"76.7836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"166.6919\" y=\"-238.6233\">lev('big', 'g') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge18\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('big', 'g'){}</title>\n",
       "<path d=\"M242.2292,-296.2221C229.3963,-286.7461 213.4955,-275.0048 199.5978,-264.7425\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"201.3723,-261.7021 191.2487,-258.5775 197.2142,-267.3333 201.3723,-261.7021\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge17\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M192.1095,-222.5695C205.8082,-212.9359 222.8945,-200.92 237.7197,-190.4942\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"239.978,-193.1848 246.1445,-184.5694 235.9513,-187.4589 239.978,-193.1848\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge15\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M167.5927,-221.4398C168.7898,-196.1844 170.9162,-151.3224 172.3152,-121.8081\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"175.8171,-121.848 172.7946,-111.6935 168.825,-121.5166 175.8171,-121.848\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node13\">\n",
       "<title>lev('big', ''){}</title>\n",
       "<ellipse cx=\"71.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"71.8844\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"71.6919\" y=\"-164.7821\">lev('big', '') ↦ 3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge16\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('big', ''){}</title>\n",
       "<path d=\"M143.2088,-222.1915C131.0143,-212.713 115.9538,-201.0069 102.8034,-190.7854\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"104.9484,-188.0197 94.905,-184.6461 100.6525,-193.5465 104.9484,-188.0197\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge22\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M459.7829,-296.2221C445.2931,-286.4953 427.2475,-274.3816 411.6791,-263.9308\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"413.5767,-260.9891 403.3231,-258.3215 409.6752,-266.8011 413.5767,-260.9891\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge21\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M485.4051,-295.2811C483.695,-270.0257 480.6572,-225.1637 478.6587,-195.6494\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"482.1415,-195.2754 477.9738,-185.5348 475.1575,-195.7484 482.1415,-195.2754\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node15\">\n",
       "<title>lev('g', 'dog'){}</title>\n",
       "<ellipse cx=\"616.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"78.6824\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"616.6919\" y=\"-238.6233\">lev('g', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge26\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('g', 'dog'){}</title>\n",
       "<path d=\"M517.8302,-296.5989C535.598,-286.5065 558.0493,-273.754 577.0643,-262.9533\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"578.8412,-265.9693 585.8078,-257.9869 575.3839,-259.8826 578.8412,-265.9693\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge24\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M583.8681,-223.1319C564.2965,-212.8091 539.2626,-199.6053 518.3119,-188.5551\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"519.788,-185.3767 509.3101,-183.8072 516.5223,-191.5683 519.788,-185.3767\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge23\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('', 'og'){}</title>\n",
       "<path d=\"M670.6847,-226.5956C691.6245,-218.3015 713.4682,-205.3705 725.6919,-185.5238 739.2314,-163.5408 722.8617,-137.316 705.6645,-118.3681\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"708.0313,-115.7792 698.5853,-110.9808 702.9773,-120.6225 708.0313,-115.7792\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node16\">\n",
       "<title>lev('', 'dog'){}</title>\n",
       "<ellipse cx=\"642.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"73.7827\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"642.6919\" y=\"-164.7821\">lev('', 'dog') ↦ 3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge25\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('', 'dog'){}</title>\n",
       "<path d=\"M623.3876,-221.4285C626.208,-213.4183 629.5508,-203.9245 632.6555,-195.1071\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"635.999,-196.1495 636.019,-185.5547 629.3964,-193.8246 635.999,-196.1495\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "@lru_cache()\n",
    "def lev(a, b):\n",
    "    if \"\" in (a, b):\n",
    "        return len(a) + len(b)\n",
    "\n",
    "    candidates = []\n",
    "    if a[0] == b[0]:\n",
    "        candidates.append(lev(a[1:], b[1:]))\n",
    "    else:\n",
    "        candidates.append(lev(a[1:], b[1:]) + 1)\n",
    "    candidates.append(lev(a, b[1:]) + 1)\n",
    "    candidates.append(lev(a[1:], b) + 1)\n",
    "    return min(candidates)\n",
    "\n",
    "%callgraph lev(\"big\", \"dog\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`%callgraph` accepts multiple statements. Here, we can see how computation results are re-used between statements."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"313pt\" viewBox=\"0.00 0.00 720.00 313.36\" width=\"720pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(.755 .755) rotate(0) translate(4 411.0476)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-411.0476 949.6335,-411.0476 949.6335,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- lev(&#39;&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>lev('', ''){}</title>\n",
       "<ellipse cx=\"573.6919\" cy=\"-18.9206\" fill=\"none\" rx=\"59.0841\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"573.6919\" y=\"-17.0995\">lev('', '') ↦ 0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>lev('g', 'g'){}</title>\n",
       "<ellipse cx=\"573.6919\" cy=\"-92.7619\" fill=\"none\" rx=\"68.8831\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"573.6919\" y=\"-90.9408\">lev('g', 'g') ↦ 0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('', ''){}</title>\n",
       "<path d=\"M573.6919,-73.7459C573.6919,-65.908 573.6919,-56.6496 573.6919,-47.9944\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"577.192,-47.8721 573.6919,-37.8721 570.192,-47.8722 577.192,-47.8721\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>lev('g', ''){}</title>\n",
       "<ellipse cx=\"432.6919\" cy=\"-18.9206\" fill=\"none\" rx=\"63.9836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"432.6919\" y=\"-17.0995\">lev('g', '') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('g', ''){}</title>\n",
       "<path d=\"M541.3437,-75.8212C521.1395,-65.2403 494.9529,-51.5265 473.3504,-40.2134\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"474.8862,-37.0668 464.4037,-35.528 471.6387,-43.2679 474.8862,-37.0668\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>lev('', 'g'){}</title>\n",
       "<ellipse cx=\"714.6919\" cy=\"-18.9206\" fill=\"none\" rx=\"63.9836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"714.6919\" y=\"-17.0995\">lev('', 'g') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('', 'g'){}</title>\n",
       "<path d=\"M606.0402,-75.8212C626.2444,-65.2403 652.431,-51.5265 674.0334,-40.2134\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"675.7452,-43.2679 682.9801,-35.528 672.4976,-37.0668 675.7452,-43.2679\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>lev('ig', 'og'){}</title>\n",
       "<ellipse cx=\"575.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"76.7836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"575.6919\" y=\"-238.6233\">lev('ig', 'og') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M575.4346,-221.4398C575.0925,-196.1844 574.485,-151.3224 574.0853,-121.8081\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"577.5835,-121.6452 573.9483,-111.6935 570.5841,-121.74 577.5835,-121.6452\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>lev('ig', 'g'){}</title>\n",
       "<ellipse cx=\"470.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"71.8844\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"470.6919\" y=\"-164.7821\">lev('ig', 'g') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M550.2744,-222.5695C536.5757,-212.9359 519.4894,-200.92 504.6642,-190.4942\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"506.4326,-187.4589 496.2394,-184.5694 502.4058,-193.1848 506.4326,-187.4589\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>lev('g', 'og'){}</title>\n",
       "<ellipse cx=\"675.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"73.7827\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"675.6919\" y=\"-164.7821\">lev('g', 'og') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge12\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M600.1547,-222.3808C613.0833,-212.8341 629.1258,-200.9882 643.0968,-190.6718\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"645.5163,-193.2361 651.4817,-184.4803 641.3581,-187.6049 645.5163,-193.2361\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M495.6254,-148.7282C509.1627,-139.0233 526.0725,-126.9006 540.6895,-116.4215\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"542.9001,-119.1432 548.9881,-110.4722 538.8216,-113.4542 542.9001,-119.1432\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('g', ''){}</title>\n",
       "<path d=\"M465.8019,-147.5986C459.2749,-122.2324 447.6587,-77.0873 440.0661,-47.5794\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"443.4448,-46.6646 437.5632,-37.8523 436.6656,-48.409 443.4448,-46.6646\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>lev('ig', ''){}</title>\n",
       "<ellipse cx=\"209.6919\" cy=\"-92.7619\" fill=\"none\" rx=\"66.9852\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"209.6919\" y=\"-90.9408\">lev('ig', '') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M421.5998,-152.7142C377.7143,-140.2982 313.3781,-122.0964 267.1189,-109.0089\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"267.8184,-105.5695 257.2433,-106.215 265.9128,-112.3052 267.8184,-105.5695\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M651.0006,-148.7282C637.5947,-139.0233 620.8491,-126.9006 606.3739,-116.4215\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"608.3085,-113.5012 598.1559,-110.4722 604.2037,-119.1713 608.3085,-113.5012\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('', 'g'){}</title>\n",
       "<path d=\"M680.7107,-147.5986C687.4094,-122.2324 699.3313,-77.0873 707.1237,-47.5794\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"710.5231,-48.4145 709.6925,-37.8523 703.7551,-46.6271 710.5231,-48.4145\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>lev('', 'og'){}</title>\n",
       "<ellipse cx=\"876.6919\" cy=\"-92.7619\" fill=\"none\" rx=\"68.8831\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"876.6919\" y=\"-90.9408\">lev('', 'og') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge11\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('', 'og'){}</title>\n",
       "<path d=\"M718.3189,-150.9433C749.6793,-139.4225 792.4445,-123.7118 825.6313,-111.52\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"826.9792,-114.7536 835.1589,-108.0199 824.5653,-108.183 826.9792,-114.7536\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>lev('big', 'dog'){}</title>\n",
       "<ellipse cx=\"668.6919\" cy=\"-388.1269\" fill=\"none\" rx=\"86.5824\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"668.6919\" y=\"-386.3058\">lev('big', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge13\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M656.059,-369.1529C649.0915,-358.6138 640.3294,-345.2377 632.6919,-333.2063 618.913,-311.5001 603.6847,-286.6727 592.4372,-268.1686\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"595.2827,-266.1111 587.1034,-259.3769 589.298,-269.7419 595.2827,-266.1111\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>lev('big', 'og'){}</title>\n",
       "<ellipse cx=\"465.6919\" cy=\"-314.2857\" fill=\"none\" rx=\"81.6829\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"465.6919\" y=\"-312.4646\">lev('big', 'og') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge20\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('big', 'og'){}</title>\n",
       "<path d=\"M623.8914,-371.8307C593.0995,-360.6302 552.0571,-345.701 519.493,-333.8558\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"520.2739,-330.4156 509.6798,-330.2863 517.881,-336.9939 520.2739,-330.4156\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node14\">\n",
       "<title>lev('ig', 'dog'){}</title>\n",
       "<ellipse cx=\"723.6919\" cy=\"-314.2857\" fill=\"none\" rx=\"81.6829\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"723.6919\" y=\"-312.4646\">lev('ig', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge27\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('ig', 'dog'){}</title>\n",
       "<path d=\"M682.8558,-369.111C689.1916,-360.6047 696.7736,-350.4254 703.675,-341.1597\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"706.5999,-343.0921 709.7665,-332.9816 700.986,-338.9107 706.5999,-343.0921\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge19\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M492.601,-296.2221C507.0908,-286.4953 525.1363,-274.3816 540.7048,-263.9308\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"542.7087,-266.8011 549.0607,-258.3215 538.8072,-260.9891 542.7087,-266.8011\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge14\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M466.3354,-295.2811C467.1904,-270.0257 468.7093,-225.1637 469.7085,-195.6494\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"473.2105,-195.6475 470.051,-185.5348 466.2145,-195.4106 473.2105,-195.6475\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node12\">\n",
       "<title>lev('big', 'g'){}</title>\n",
       "<ellipse cx=\"327.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"76.7836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"327.6919\" y=\"-238.6233\">lev('big', 'g') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge18\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('big', 'g'){}</title>\n",
       "<path d=\"M432.9879,-296.7863C413.9112,-286.5788 389.66,-273.6024 369.241,-262.6765\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"370.6297,-259.4501 360.1612,-257.8182 367.3271,-265.6221 370.6297,-259.4501\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge17\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M360.8584,-223.3181C381.0727,-212.8801 407.0906,-199.4451 428.7293,-188.2715\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"430.4258,-191.3346 437.7053,-183.6365 427.2141,-185.1149 430.4258,-191.3346\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge15\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M282.341,-225.17C263.0323,-216.4538 241.9501,-203.5872 228.6919,-185.5238 215.3144,-167.2978 210.8268,-141.8822 209.5382,-122.2624\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"213.0258,-121.8879 209.1153,-112.0412 206.0318,-122.1774 213.0258,-121.8879\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node13\">\n",
       "<title>lev('big', ''){}</title>\n",
       "<ellipse cx=\"309.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"71.8844\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"309.6919\" y=\"-164.7821\">lev('big', '') ↦ 3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge16\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('big', ''){}</title>\n",
       "<path d=\"M323.0565,-221.4285C321.1249,-213.5044 318.8393,-204.1285 316.7096,-195.3918\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"320.0805,-194.4412 314.3117,-185.5547 313.2796,-196.0991 320.0805,-194.4412\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge22\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M688.9925,-296.9732C668.1349,-286.5668 641.4091,-273.2325 619.153,-262.1283\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"620.4291,-258.8536 609.9184,-257.521 617.304,-265.1173 620.4291,-258.8536\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge21\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M717.515,-295.2811C709.2705,-269.9149 694.5973,-224.7698 685.0066,-195.2619\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"688.2648,-193.9632 681.8451,-185.5348 681.6076,-196.127 688.2648,-193.9632\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node15\">\n",
       "<title>lev('g', 'dog'){}</title>\n",
       "<ellipse cx=\"828.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"78.6824\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"828.6919\" y=\"-238.6233\">lev('g', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge26\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('g', 'dog'){}</title>\n",
       "<path d=\"M749.3778,-296.2221C762.9794,-286.6567 779.8634,-274.7831 794.5532,-264.4525\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"796.7408,-267.1929 802.9073,-258.5775 792.7141,-261.467 796.7408,-267.1929\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge24\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M793.2061,-223.3181C771.2293,-212.7116 742.8409,-199.0108 719.472,-187.7324\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"720.9851,-184.5764 710.4578,-183.382 717.9425,-190.8806 720.9851,-184.5764\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge23\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('', 'og'){}</title>\n",
       "<path d=\"M875.9065,-225.2902C894.5302,-216.7346 913.9987,-203.9607 924.6919,-185.5238 933.1299,-170.9753 930.6029,-163.4279 924.6919,-147.6825 920.6029,-136.7904 913.2665,-126.6426 905.5403,-118.1078\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"907.8868,-115.4995 898.4171,-110.748 902.8568,-120.3678 907.8868,-115.4995\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node16\">\n",
       "<title>lev('', 'dog'){}</title>\n",
       "<ellipse cx=\"841.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"73.7827\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"841.6919\" y=\"-164.7821\">lev('', 'dog') ↦ 3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge25\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('', 'dog'){}</title>\n",
       "<path d=\"M832.0397,-221.4285C833.4196,-213.5905 835.0496,-204.3321 836.5734,-195.6769\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"840.0685,-196.0101 838.3554,-185.5547 833.1745,-194.7963 840.0685,-196.0101\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node17\">\n",
       "<title>lev('dig', 'dog'){}</title>\n",
       "<ellipse cx=\"477.6919\" cy=\"-388.1269\" fill=\"none\" rx=\"86.5824\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"477.6919\" y=\"-386.3058\">lev('dig', 'dog') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge28\">\n",
       "<title>lev('dig', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M513.9748,-370.8561C529.4018,-361.7368 546.2138,-349.1068 556.6919,-333.2063 569.1323,-314.3282 573.6897,-288.9612 575.2436,-269.5259\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"578.7449,-269.6033 575.8288,-259.4177 571.7566,-269.1987 578.7449,-269.6033\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge36\">\n",
       "<title>lev('dig', 'dog'){}-&gt;lev('ig', 'dog'){}</title>\n",
       "<path d=\"M528.6633,-372.827C568.01,-361.0164 622.5402,-344.6482 663.9387,-332.2217\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"665.056,-335.5406 673.6276,-329.3134 663.0435,-328.8362 665.056,-335.5406\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node18\">\n",
       "<title>lev('dig', 'og'){}</title>\n",
       "<ellipse cx=\"284.6919\" cy=\"-314.2857\" fill=\"none\" rx=\"81.6829\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"284.6919\" y=\"-312.4646\">lev('dig', 'og') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;dig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge35\">\n",
       "<title>lev('dig', 'dog'){}-&gt;lev('dig', 'og'){}</title>\n",
       "<path d=\"M434.379,-371.5555C405.4969,-360.5053 367.3709,-345.9184 336.8255,-334.2318\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"337.7863,-330.8521 327.1959,-330.5476 335.2849,-337.3899 337.7863,-330.8521\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge34\">\n",
       "<title>lev('dig', 'og'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M339.7689,-300.3099C388.7375,-287.8841 460.3451,-269.7137 511.8122,-256.6539\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"512.9924,-259.9654 521.8243,-254.1133 511.2707,-253.1805 512.9924,-259.9654\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge29\">\n",
       "<title>lev('dig', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M338.0839,-299.8461C363.0702,-291.1342 392.0237,-278.0329 413.6919,-259.365 433.9977,-241.871 449.2965,-215.2975 458.9052,-195.0697\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"462.205,-196.2686 463.1621,-185.7171 455.8339,-193.3687 462.205,-196.2686\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node19\">\n",
       "<title>lev('dig', 'g'){}</title>\n",
       "<ellipse cx=\"156.6919\" cy=\"-240.4444\" fill=\"none\" rx=\"76.7836\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"156.6919\" y=\"-238.6233\">lev('dig', 'g') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;dig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge33\">\n",
       "<title>lev('dig', 'og'){}-&gt;lev('dig', 'g'){}</title>\n",
       "<path d=\"M254.0327,-296.5989C236.6174,-286.5522 214.6323,-273.8694 195.9643,-263.1\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"197.5119,-259.9522 187.1009,-257.9869 194.014,-266.0156 197.5119,-259.9522\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge32\">\n",
       "<title>lev('dig', 'g'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M212.4884,-227.3771C259.9007,-216.2665 329.7667,-199.8781 390.6919,-185.5238 395.9881,-184.276 401.4812,-182.9802 406.9949,-181.6784\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"407.9765,-185.0429 416.9041,-179.3377 406.3673,-178.2304 407.9765,-185.0429\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge30\">\n",
       "<title>lev('dig', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M163.5122,-221.4398C172.6156,-196.0737 188.8172,-150.9285 199.4069,-121.4206\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"202.8142,-122.288 202.8978,-111.6935 196.2256,-119.9235 202.8142,-122.288\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node20\">\n",
       "<title>lev('dig', ''){}</title>\n",
       "<ellipse cx=\"71.6919\" cy=\"-166.6032\" fill=\"none\" rx=\"71.8844\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"71.6919\" y=\"-164.7821\">lev('dig', '') ↦ 3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;dig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge31\">\n",
       "<title>lev('dig', 'g'){}-&gt;lev('dig', ''){}</title>\n",
       "<path d=\"M135.6807,-222.1915C125.0556,-212.9612 111.9988,-201.6185 100.4564,-191.5915\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"102.6006,-188.8179 92.756,-184.902 98.0099,-194.1024 102.6006,-188.8179\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph -w10 lev(\"big\", \"dog\"); lev(\"dig\", \"dog\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Options"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`-w` sets the maximum width of the graph:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"170pt\" viewBox=\"0.00 0.00 360.00 169.99\" width=\"360pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(.6358 .6358) rotate(0) translate(4 263.365)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-263.365 562.2038,-263.365 562.2038,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- nchoosek(2, 0){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>nchoosek(2, 0){}</title>\n",
       "<ellipse cx=\"87.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"87.1019\" y=\"-90.9408\">nchoosek(2, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>nchoosek(3, 1){}</title>\n",
       "<ellipse cx=\"183.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.1019\" y=\"-164.7821\">nchoosek(3, 1) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 0){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 0){}</title>\n",
       "<path d=\"M159.3715,-148.3503C147.1406,-138.9425 132.0567,-127.3402 118.8387,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"120.9523,-114.3834 110.8919,-111.0607 116.6845,-119.9319 120.9523,-114.3834\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>nchoosek(2, 1){}</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-90.9408\">nchoosek(2, 1) ↦ 2</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M206.8322,-148.3503C219.0631,-138.9425 234.1471,-127.3402 247.3651,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"249.5193,-119.9319 255.3118,-111.0607 245.2515,-114.3834 249.5193,-119.9319\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 0){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>nchoosek(1, 0){}</title>\n",
       "<ellipse cx=\"183.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.1019\" y=\"-17.0995\">nchoosek(1, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 0){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 0){}</title>\n",
       "<path d=\"M255.3715,-74.509C243.1406,-65.1012 228.0567,-53.499 214.8387,-43.332\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"216.9523,-40.5421 206.8919,-37.2195 212.6845,-46.0906 216.9523,-40.5421\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 1){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>nchoosek(1, 1){}</title>\n",
       "<ellipse cx=\"375.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"375.1019\" y=\"-17.0995\">nchoosek(1, 1) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 1){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 1){}</title>\n",
       "<path d=\"M302.8322,-74.509C315.0631,-65.1012 330.1471,-53.499 343.3651,-43.332\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"345.5193,-46.0906 351.3118,-37.2195 341.2515,-40.5421 345.5193,-46.0906\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>nchoosek(4, 2){}</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-240.4444\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-238.6233\">nchoosek(4, 2) ↦ 6</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 1){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 1){}</title>\n",
       "<path d=\"M255.3715,-222.1915C243.1406,-212.7837 228.0567,-201.1815 214.8387,-191.0145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"216.9523,-188.2246 206.8919,-184.902 212.6845,-193.7731 216.9523,-188.2246\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>nchoosek(3, 2){}</title>\n",
       "<ellipse cx=\"375.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"375.1019\" y=\"-164.7821\">nchoosek(3, 2) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 2){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 2){}</title>\n",
       "<path d=\"M302.8322,-222.1915C315.0631,-212.7837 330.1471,-201.1815 343.3651,-191.0145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"345.5193,-193.7731 351.3118,-184.902 341.2515,-188.2246 345.5193,-193.7731\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M351.3715,-148.3503C339.1406,-138.9425 324.0567,-127.3402 310.8387,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"312.9523,-114.3834 302.8919,-111.0607 308.6845,-119.9319 312.9523,-114.3834\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 2){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>nchoosek(2, 2){}</title>\n",
       "<ellipse cx=\"471.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"471.1019\" y=\"-90.9408\">nchoosek(2, 2) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 2){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 2){}</title>\n",
       "<path d=\"M398.8322,-148.3503C411.0631,-138.9425 426.1471,-127.3402 439.3651,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"441.5193,-119.9319 447.3118,-111.0607 437.2515,-114.3834 441.5193,-119.9319\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph -w5 nchoosek(4, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`-h` turns the graph sideways. It displays functions calls as *horizontal* arrows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"130pt\" viewBox=\"0.00 0.00 720.00 129.54\" width=\"720pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(.6971 .6971) rotate(0) translate(4 181.8413)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-181.8413 1028.9183,-181.8413 1028.9183,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- nchoosek(3, 0){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>nchoosek(3, 0){}</title>\n",
       "<ellipse cx=\"517.4089\" cy=\"-158.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"517.4089\" y=\"-157.0995\">nchoosek(3, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 1){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>nchoosek(4, 1){}</title>\n",
       "<ellipse cx=\"307.2051\" cy=\"-130.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"307.2051\" y=\"-129.0995\">nchoosek(4, 1) ↦ 4</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 1){}&#45;&gt;nchoosek(3, 0){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>nchoosek(4, 1){}-&gt;nchoosek(3, 0){}</title>\n",
       "<path d=\"M381.6109,-140.8318C398.2959,-143.0543 416.1121,-145.4275 433.1651,-147.699\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"432.7285,-151.1717 443.1031,-149.0228 433.6528,-144.233 432.7285,-151.1717\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>nchoosek(3, 1){}</title>\n",
       "<ellipse cx=\"517.4089\" cy=\"-102.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"517.4089\" y=\"-101.0995\">nchoosek(3, 1) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 1){}&#45;&gt;nchoosek(3, 1){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>nchoosek(4, 1){}-&gt;nchoosek(3, 1){}</title>\n",
       "<path d=\"M381.6109,-121.0095C398.2959,-118.787 416.1121,-116.4138 433.1651,-114.1423\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"433.6528,-117.6083 443.1031,-112.8185 432.7285,-110.6696 433.6528,-117.6083\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 0){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>nchoosek(2, 0){}</title>\n",
       "<ellipse cx=\"727.6127\" cy=\"-130.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"727.6127\" y=\"-129.0995\">nchoosek(2, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 0){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 0){}</title>\n",
       "<path d=\"M591.8147,-112.8318C608.4996,-115.0543 626.3159,-117.4275 643.3688,-119.699\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"642.9322,-123.1717 653.3069,-121.0228 643.8566,-116.233 642.9322,-123.1717\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>nchoosek(2, 1){}</title>\n",
       "<ellipse cx=\"727.6127\" cy=\"-74.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"727.6127\" y=\"-73.0995\">nchoosek(2, 1) ↦ 2</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M591.8147,-93.0095C608.4996,-90.787 626.3159,-88.4138 643.3688,-86.1423\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"643.8566,-89.6083 653.3069,-84.8185 642.9322,-82.6696 643.8566,-89.6083\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 0){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>nchoosek(1, 0){}</title>\n",
       "<ellipse cx=\"937.8164\" cy=\"-102.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"937.8164\" y=\"-101.0995\">nchoosek(1, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 0){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 0){}</title>\n",
       "<path d=\"M802.0185,-84.8318C818.7034,-87.0543 836.5196,-89.4275 853.5726,-91.699\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"853.136,-95.1717 863.5106,-93.0228 854.0603,-88.233 853.136,-95.1717\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 1){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>nchoosek(1, 1){}</title>\n",
       "<ellipse cx=\"937.8164\" cy=\"-46.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"937.8164\" y=\"-45.0995\">nchoosek(1, 1) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 1){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 1){}</title>\n",
       "<path d=\"M802.0185,-65.0095C818.7034,-62.787 836.5196,-60.4138 853.5726,-58.1423\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"854.0603,-61.6083 863.5106,-56.8185 853.136,-54.6696 854.0603,-61.6083\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(5, 2){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>nchoosek(5, 2){}</title>\n",
       "<ellipse cx=\"92.0516\" cy=\"-102.9206\" fill=\"none\" rx=\"92.1033\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"92.0516\" y=\"-101.0995\">nchoosek(5, 2) ↦ 10</text>\n",
       "</g>\n",
       "<!-- nchoosek(5, 2){}&#45;&gt;nchoosek(4, 1){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>nchoosek(5, 2){}-&gt;nchoosek(4, 1){}</title>\n",
       "<path d=\"M170.0312,-113.0689C187.0208,-115.2799 205.0783,-117.6299 222.321,-119.8738\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"221.9967,-123.3611 232.3648,-121.1809 222.9001,-116.4196 221.9967,-123.3611\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){} -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>nchoosek(4, 2){}</title>\n",
       "<ellipse cx=\"307.2051\" cy=\"-74.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"307.2051\" y=\"-73.0995\">nchoosek(4, 2) ↦ 6</text>\n",
       "</g>\n",
       "<!-- nchoosek(5, 2){}&#45;&gt;nchoosek(4, 2){} -->\n",
       "<g class=\"edge\" id=\"edge12\">\n",
       "<title>nchoosek(5, 2){}-&gt;nchoosek(4, 2){}</title>\n",
       "<path d=\"M170.0312,-92.7724C187.0208,-90.5614 205.0783,-88.2114 222.321,-85.9674\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"222.9001,-89.4217 232.3648,-84.6603 221.9967,-82.4802 222.9001,-89.4217\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 1){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 1){}</title>\n",
       "<path d=\"M381.6109,-84.8318C398.2959,-87.0543 416.1121,-89.4275 433.1651,-91.699\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"432.7285,-95.1717 443.1031,-93.0228 433.6528,-88.233 432.7285,-95.1717\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){} -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>nchoosek(3, 2){}</title>\n",
       "<ellipse cx=\"517.4089\" cy=\"-46.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"517.4089\" y=\"-45.0995\">nchoosek(3, 2) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 2){} -->\n",
       "<g class=\"edge\" id=\"edge11\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 2){}</title>\n",
       "<path d=\"M381.6109,-65.0095C398.2959,-62.787 416.1121,-60.4138 433.1651,-58.1423\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"433.6528,-61.6083 443.1031,-56.8185 432.7285,-54.6696 433.6528,-61.6083\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M591.8147,-56.8318C608.4996,-59.0543 626.3159,-61.4275 643.3688,-63.699\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"642.9322,-67.1717 653.3069,-65.0228 643.8566,-60.233 642.9322,-67.1717\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 2){} -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>nchoosek(2, 2){}</title>\n",
       "<ellipse cx=\"727.6127\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"727.6127\" y=\"-17.0995\">nchoosek(2, 2) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 2){} -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 2){}</title>\n",
       "<path d=\"M591.8147,-37.0095C608.4996,-34.787 626.3159,-32.4138 643.3688,-30.1423\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"643.8566,-33.6083 653.3069,-28.8185 642.9322,-26.6696 643.8566,-33.6083\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph -w10 -h nchoosek(5, 2); nchoosek(3, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use `-r` to *reverse* the arrows, and label them with *return* values:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"143pt\" viewBox=\"0.00 0.00 720.00 143.33\" width=\"720pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(.7875 .7875) rotate(0) translate(4 178)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-178 910.2814,-178 910.2814,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- nchoosek(3, 0){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>nchoosek(3, 0){}</title>\n",
       "<ellipse cx=\"482.5299\" cy=\"-156\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"482.5299\" y=\"-151.8\">nchoosek(3, 0)</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 1){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>nchoosek(4, 1){}</title>\n",
       "<ellipse cx=\"289.7657\" cy=\"-127\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"289.7657\" y=\"-122.8\">nchoosek(4, 1)</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 1){}&#45;&gt;nchoosek(3, 0){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>nchoosek(4, 1){}-&gt;nchoosek(3, 0){}</title>\n",
       "<path d=\"M355.624,-136.9079C378.8152,-140.3969 404.6355,-144.2813 426.8998,-147.6308\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"355.9305,-133.4147 345.5211,-135.388 354.8891,-140.3368 355.9305,-133.4147\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"373.9281\" y=\"-141.8\">1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>nchoosek(3, 1){}</title>\n",
       "<ellipse cx=\"482.5299\" cy=\"-101\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"482.5299\" y=\"-96.8\">nchoosek(3, 1)</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 1){}&#45;&gt;nchoosek(3, 1){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>nchoosek(4, 1){}-&gt;nchoosek(3, 1){}</title>\n",
       "<path d=\"M356.6759,-117.9752C379.0997,-114.9506 403.8784,-111.6085 425.4767,-108.6953\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"356.0011,-114.5344 346.5587,-119.3398 356.9368,-121.4716 356.0011,-114.5344\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"373.9281\" y=\"-117.8\">3</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 0){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>nchoosek(2, 0){}</title>\n",
       "<ellipse cx=\"675.2942\" cy=\"-129\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"675.2942\" y=\"-124.8\">nchoosek(2, 0)</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 0){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 0){}</title>\n",
       "<path d=\"M548.5527,-110.5901C571.5196,-113.9262 597.0481,-117.6344 619.1402,-120.8433\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"548.9436,-107.1103 538.5443,-109.1364 547.9373,-114.0376 548.9436,-107.1103\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"591.1318\" y=\"-118.8\">1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>nchoosek(2, 1){}</title>\n",
       "<ellipse cx=\"675.2942\" cy=\"-74\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"675.2942\" y=\"-69.8\">nchoosek(2, 1)</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M548.9719,-91.6936C571.6989,-88.5103 596.8918,-84.9816 618.7621,-81.9183\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"548.4809,-88.2282 539.0631,-93.0815 549.452,-95.1605 548.4809,-88.2282\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"591.1318\" y=\"-87.8\">2</text>\n",
       "</g>\n",
       "<!-- nchoosek(1, 0){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>nchoosek(1, 0){}</title>\n",
       "<ellipse cx=\"843.619\" cy=\"-101\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"843.619\" y=\"-96.8\">nchoosek(1, 0)</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 0){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 0){}</title>\n",
       "<path d=\"M740.6745,-84.4873C756.5384,-87.0319 773.3404,-89.727 788.667,-92.1855\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"740.8382,-80.9689 730.4101,-82.8408 739.7295,-87.8805 740.8382,-80.9689\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"759.4566\" y=\"-89.8\">1</text>\n",
       "</g>\n",
       "<!-- nchoosek(1, 1){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>nchoosek(1, 1){}</title>\n",
       "<ellipse cx=\"843.619\" cy=\"-47\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"843.619\" y=\"-42.8\">nchoosek(1, 1)</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 1){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 1){}</title>\n",
       "<path d=\"M740.6745,-63.5127C756.5384,-60.9681 773.3404,-58.273 788.667,-55.8145\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"739.7295,-60.1195 730.4101,-65.1592 740.8382,-67.0311 739.7295,-60.1195\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"759.4566\" y=\"-63.8\">1</text>\n",
       "</g>\n",
       "<!-- nchoosek(5, 2){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>nchoosek(5, 2){}</title>\n",
       "<ellipse cx=\"92.0516\" cy=\"-99\" fill=\"none\" rx=\"92.1033\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"92.0516\" y=\"-97.1789\">nchoosek(5, 2) ↦ 10</text>\n",
       "</g>\n",
       "<!-- nchoosek(5, 2){}&#45;&gt;nchoosek(4, 1){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>nchoosek(5, 2){}-&gt;nchoosek(4, 1){}</title>\n",
       "<path d=\"M177.9753,-111.1684C196.7544,-113.8279 216.167,-116.5771 233.4394,-119.0232\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"178.3196,-107.6823 167.9276,-109.7455 177.338,-114.6132 178.3196,-107.6823\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"205.6033\" y=\"-117.8\">4</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){} -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>nchoosek(4, 2){}</title>\n",
       "<ellipse cx=\"289.7657\" cy=\"-73\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"289.7657\" y=\"-68.8\">nchoosek(4, 2)</text>\n",
       "</g>\n",
       "<!-- nchoosek(5, 2){}&#45;&gt;nchoosek(4, 2){} -->\n",
       "<g class=\"edge\" id=\"edge12\">\n",
       "<title>nchoosek(5, 2){}-&gt;nchoosek(4, 2){}</title>\n",
       "<path d=\"M179.5471,-87.4941C197.5268,-85.1297 216.0146,-82.6985 232.5889,-80.5189\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"179.0843,-84.0247 169.626,-88.7987 179.997,-90.965 179.0843,-84.0247\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"205.6033\" y=\"-86.8\">6</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 1){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 1){}</title>\n",
       "<path d=\"M355.7884,-82.5901C378.7554,-85.9262 404.2838,-89.6344 426.3759,-92.8433\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"356.1793,-79.1103 345.78,-81.1364 355.173,-86.0376 356.1793,-79.1103\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"373.9281\" y=\"-87.8\">3</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){} -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>nchoosek(3, 2){}</title>\n",
       "<ellipse cx=\"482.5299\" cy=\"-45\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"482.5299\" y=\"-43.1789\">nchoosek(3, 2) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(4, 2){}&#45;&gt;nchoosek(3, 2){} -->\n",
       "<g class=\"edge\" id=\"edge11\">\n",
       "<title>nchoosek(4, 2){}-&gt;nchoosek(3, 2){}</title>\n",
       "<path d=\"M355.8372,-63.4028C373.24,-60.8749 392.1106,-58.1339 409.8407,-55.5585\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"355.173,-59.9624 345.78,-64.8636 356.1793,-66.8897 355.173,-59.9624\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"373.9281\" y=\"-63.8\">3</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M564.2969,-57.3012C582.9889,-60.1133 602.4318,-63.0384 619.7247,-65.64\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"564.7177,-53.8252 554.3082,-55.7985 563.6762,-60.7474 564.7177,-53.8252\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"591.1318\" y=\"-64.8\">2</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 2){} -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>nchoosek(2, 2){}</title>\n",
       "<ellipse cx=\"675.2942\" cy=\"-18\" fill=\"none\" rx=\"62.8252\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"675.2942\" y=\"-13.8\">nchoosek(2, 2)</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 2){}&#45;&gt;nchoosek(2, 2){} -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>nchoosek(3, 2){}-&gt;nchoosek(2, 2){}</title>\n",
       "<path d=\"M544.3012,-27.2024C558.4242,-23.8386 573.4532,-20.8098 587.6318,-19 595.6336,-17.9786 604.0795,-17.3373 612.4427,-16.9624\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"543.0707,-23.9011 534.2027,-29.6983 544.7504,-30.6966 543.0707,-23.9011\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"591.1318\" y=\"-21.8\">1</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph -w10 -hr nchoosek(5, 2); nchoosek(3, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"471pt\" viewBox=\"0.00 0.00 720.00 471.23\" width=\"720pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(.9903 .9903) rotate(0) translate(4 471.8413)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-471.8413 723.0392,-471.8413 723.0392,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- lev(&#39;&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>lev('', ''){}</title>\n",
       "<ellipse cx=\"289.1429\" cy=\"-18\" fill=\"none\" rx=\"37.6919\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"289.1429\" y=\"-13.8\">lev('', '')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>lev('g', 'g'){}</title>\n",
       "<ellipse cx=\"284.1429\" cy=\"-104\" fill=\"none\" rx=\"46.3787\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"284.1429\" y=\"-99.8\">lev('g', 'g')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('', ''){}</title>\n",
       "<path d=\"M285.8013,-75.4762C286.5538,-62.5329 287.4215,-47.6086 288.0841,-36.2121\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"282.2897,-75.5753 285.2033,-85.7616 289.2779,-75.9816 282.2897,-75.5753\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"290.6429\" y=\"-56.8\">0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>lev('g', ''){}</title>\n",
       "<ellipse cx=\"411.1429\" cy=\"-18\" fill=\"none\" rx=\"42.0351\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"411.1429\" y=\"-13.8\">lev('g', '')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('g', ''){}</title>\n",
       "<path d=\"M315.999,-82.4281C338.5473,-67.1592 368.2467,-47.0478 388.4241,-33.3844\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"313.7544,-79.7211 307.4367,-88.2263 317.6793,-85.5173 313.7544,-79.7211\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"359.6429\" y=\"-56.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>lev('', 'g'){}</title>\n",
       "<ellipse cx=\"191.1429\" cy=\"-18\" fill=\"none\" rx=\"42.0351\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"191.1429\" y=\"-13.8\">lev('', 'g')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>lev('g', 'g'){}-&gt;lev('', 'g'){}</title>\n",
       "<path d=\"M258.3943,-80.1895C242.6295,-65.6113 222.8613,-47.331 208.8475,-34.372\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"256.0508,-82.7895 265.7691,-87.0092 260.8034,-77.6501 256.0508,-82.7895\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"247.6429\" y=\"-56.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>lev('ig', 'og'){}</title>\n",
       "<ellipse cx=\"279.1429\" cy=\"-276\" fill=\"none\" rx=\"53.1367\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1429\" y=\"-271.8\">lev('ig', 'og')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M279.965,-247.7199C280.9996,-212.1302 282.7462,-152.0454 283.6168,-122.0977\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"276.4607,-247.8206 279.6685,-257.9181 283.4577,-248.024 276.4607,-247.8206\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"285.6429\" y=\"-185.8\">0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>lev('ig', 'g'){}</title>\n",
       "<ellipse cx=\"468.1429\" cy=\"-190\" fill=\"none\" rx=\"48.7928\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"468.1429\" y=\"-185.8\">lev('ig', 'g')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M312.7898,-254.4365C328.3526,-244.9896 347.3076,-234.2107 365.1429,-226 385.9633,-216.4152 410.1125,-207.8484 429.7924,-201.4787\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"310.7336,-251.5922 304.0528,-259.8152 314.4034,-257.5532 310.7336,-251.5922\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"368.6429\" y=\"-228.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>lev('g', 'og'){}</title>\n",
       "<ellipse cx=\"191.1429\" cy=\"-190\" fill=\"none\" rx=\"50.7224\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"191.1429\" y=\"-185.8\">lev('g', 'og')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge12\">\n",
       "<title>lev('ig', 'og'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M254.0923,-251.5188C239.5644,-237.321 221.6293,-219.7935 208.6242,-207.084\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"251.7366,-254.1104 261.3348,-258.5966 256.6292,-249.1041 251.7366,-254.1104\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"244.6429\" y=\"-228.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M428.4756,-171.4598C394.0919,-155.3892 345.0961,-132.489 313.9614,-117.9369\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"427.2177,-174.7353 437.759,-175.7988 430.1817,-168.3938 427.2177,-174.7353\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"391.6429\" y=\"-142.8\">0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('g', ''){}</title>\n",
       "<path d=\"M458.914,-162.1513C447.1045,-126.5156 426.9901,-65.8196 417.0549,-35.8397\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"455.6825,-163.5268 462.1506,-171.9181 462.3272,-161.3247 455.6825,-163.5268\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"449.6429\" y=\"-99.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>lev('ig', ''){}</title>\n",
       "<ellipse cx=\"553.1429\" cy=\"-104\" fill=\"none\" rx=\"44.4491\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"553.1429\" y=\"-99.8\">lev('ig', '')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>lev('ig', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M491.9743,-165.8882C506.1178,-151.5784 523.7038,-133.7854 536.3845,-120.9555\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"489.4765,-163.4365 484.9362,-173.0092 494.4551,-168.3572 489.4765,-163.4365\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"518.6429\" y=\"-142.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('g', 'g'){}</title>\n",
       "<path d=\"M217.2698,-165.8396C232.8535,-151.4289 252.2423,-133.4994 266.1237,-120.6629\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"214.4824,-163.6501 209.5167,-173.0092 219.235,-168.7895 214.4824,-163.6501\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"247.6429\" y=\"-142.8\">0</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('', 'g'){}</title>\n",
       "<path d=\"M191.1429,-161.7199C191.1429,-126.1302 191.1429,-66.0454 191.1429,-36.0977\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"187.643,-161.918 191.1429,-171.9181 194.643,-161.9181 187.643,-161.918\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"194.6429\" y=\"-99.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>lev('', 'og'){}</title>\n",
       "<ellipse cx=\"52.1429\" cy=\"-104\" fill=\"none\" rx=\"46.3787\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"52.1429\" y=\"-99.8\">lev('', 'og')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge11\">\n",
       "<title>lev('g', 'og'){}-&gt;lev('', 'og'){}</title>\n",
       "<path d=\"M156.9301,-168.8323C132.174,-153.5157 99.2877,-133.1687 77.0083,-119.3844\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"155.3027,-171.9412 165.6482,-174.2263 158.9857,-165.9884 155.3027,-171.9412\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"133.6429\" y=\"-142.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>lev('big', 'dog'){}</title>\n",
       "<ellipse cx=\"165.1429\" cy=\"-448.9206\" fill=\"none\" rx=\"86.5824\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"165.1429\" y=\"-447.0995\">lev('big', 'dog') ↦ 2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge13\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M187.3802,-422.3618C197.5018,-409.8246 209.3734,-394.4674 219.1429,-380 238.8575,-350.8052 258.6911,-314.8328 269.8948,-293.7546\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"184.6312,-420.1947 181.0213,-430.1555 190.055,-424.6199 184.6312,-420.1947\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"245.6429\" y=\"-357.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>lev('big', 'og'){}</title>\n",
       "<ellipse cx=\"404.1429\" cy=\"-362\" fill=\"none\" rx=\"57.9805\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"404.1429\" y=\"-357.8\">lev('big', 'og')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge20\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('big', 'og'){}</title>\n",
       "<path d=\"M217.6809,-428.325C229.7781,-423.2529 242.5056,-417.6482 254.1429,-412 265.5995,-406.4395 267.391,-402.9057 279.1429,-398 293.7834,-391.8885 330.0052,-381.6417 359.7095,-373.6395\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"216.0496,-425.2121 208.1472,-432.2692 218.7257,-431.6804 216.0496,-425.2121\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"282.6429\" y=\"-400.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node14\">\n",
       "<title>lev('ig', 'dog'){}</title>\n",
       "<ellipse cx=\"152.1429\" cy=\"-362\" fill=\"none\" rx=\"57.9805\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"152.1429\" y=\"-357.8\">lev('ig', 'dog')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge27\">\n",
       "<title>lev('big', 'dog'){}-&gt;lev('ig', 'dog'){}</title>\n",
       "<path d=\"M160.7629,-419.6354C158.802,-406.5239 156.5519,-391.4795 154.8424,-380.0496\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"157.317,-420.2579 162.2578,-429.6301 164.24,-419.2224 157.317,-420.2579\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"163.6429\" y=\"-400.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge19\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M372.2253,-339.7301C359.7423,-331.0478 345.2913,-321.0305 332.1429,-312 322.6988,-305.5136 312.2746,-298.4191 303.1878,-292.2557\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"370.3059,-342.6584 380.5128,-345.4991 374.3051,-336.9133 370.3059,-342.6584\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"355.6429\" y=\"-314.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge14\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M434.4403,-338.2676C447.0647,-326.4735 460.3478,-311.0905 467.1429,-294 478.4172,-265.6438 475.2417,-229.4028 471.7812,-208.0452\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"431.8722,-335.8678 426.7289,-345.1305 436.5259,-341.0968 431.8722,-335.8678\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"477.6429\" y=\"-271.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node12\">\n",
       "<title>lev('big', 'g'){}</title>\n",
       "<ellipse cx=\"405.1429\" cy=\"-276\" fill=\"none\" rx=\"53.1367\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"405.1429\" y=\"-271.8\">lev('big', 'g')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge18\">\n",
       "<title>lev('big', 'og'){}-&gt;lev('big', 'g'){}</title>\n",
       "<path d=\"M404.4746,-333.4762C404.6251,-320.5329 404.7986,-305.6086 404.9311,-294.2121\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"400.9716,-333.7216 404.355,-343.7616 407.9711,-333.803 400.9716,-333.7216\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"408.6429\" y=\"-314.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge17\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M424.1645,-250.034C434.2461,-236.2718 446.3619,-219.7329 455.3215,-207.5022\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"421.2827,-248.0453 418.1965,-258.1807 426.9296,-252.1821 421.2827,-248.0453\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"444.6429\" y=\"-228.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge15\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M453.3126,-259.5571C478.4685,-248.6408 507.7568,-231.867 526.1429,-208 545.7235,-182.5825 551.1809,-144.3725 552.6542,-122.0338\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"451.8026,-256.3942 443.905,-263.4567 454.483,-262.8607 451.8026,-256.3942\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"546.6429\" y=\"-185.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node13\">\n",
       "<title>lev('big', ''){}</title>\n",
       "<ellipse cx=\"352.1429\" cy=\"-190\" fill=\"none\" rx=\"48.7928\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"352.1429\" y=\"-185.8\">lev('big', '')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;big&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;big&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge16\">\n",
       "<title>lev('big', 'g'){}-&gt;lev('big', ''){}</title>\n",
       "<path d=\"M388.6971,-249.3144C380.3743,-235.8094 370.4979,-219.7836 363.1105,-207.7964\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"385.9351,-251.5038 394.1613,-258.1807 391.8943,-247.8313 385.9351,-251.5038\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"385.6429\" y=\"-228.8\">3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge22\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M184.494,-339.7137C197.1491,-331.0293 211.8026,-321.0149 225.1429,-312 234.852,-305.439 245.5845,-298.2674 254.9066,-292.0642\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"182.3535,-336.9378 176.0927,-345.4848 186.3171,-342.7076 182.3535,-336.9378\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"228.6429\" y=\"-314.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge21\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M158.5552,-333.7199C166.625,-298.1302 180.2489,-238.0454 187.0393,-208.0977\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"155.0409,-333.3916 156.2429,-343.9181 161.8676,-334.9396 155.0409,-333.3916\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"179.6429\" y=\"-271.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node15\">\n",
       "<title>lev('g', 'dog'){}</title>\n",
       "<ellipse cx=\"82.1429\" cy=\"-276\" fill=\"none\" rx=\"55.0664\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"82.1429\" y=\"-271.8\">lev('g', 'dog')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;ig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge26\">\n",
       "<title>lev('ig', 'dog'){}-&gt;lev('g', 'dog'){}</title>\n",
       "<path d=\"M131.3242,-336.4228C120.0603,-322.5842 106.438,-305.8482 96.3889,-293.5022\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.6116,-338.6346 137.6389,-344.1807 134.0406,-334.2156 128.6116,-338.6346\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"125.6429\" y=\"-314.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;g&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge24\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('g', 'og'){}</title>\n",
       "<path d=\"M111.3038,-252.9923C129.9041,-238.3168 153.5697,-219.6449 170.2918,-206.4513\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"109.1007,-250.2723 103.418,-259.2142 113.4366,-255.7678 109.1007,-250.2723\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"147.6429\" y=\"-228.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge23\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('', 'og'){}</title>\n",
       "<path d=\"M45.5952,-254.3828C29.7225,-242.8284 12.804,-227.0409 4.1429,-208 -9.8543,-177.2279 15.9055,-141.4632 34.7926,-120.9065\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"44.0299,-257.5555 54.2467,-260.3603 48.0089,-251.7963 44.0299,-257.5555\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"7.6429\" y=\"-185.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node16\">\n",
       "<title>lev('', 'dog'){}</title>\n",
       "<ellipse cx=\"71.1429\" cy=\"-190\" fill=\"none\" rx=\"50.7224\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"71.1429\" y=\"-185.8\">lev('', 'dog')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;g&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge25\">\n",
       "<title>lev('g', 'dog'){}-&gt;lev('', 'dog'){}</title>\n",
       "<path d=\"M78.4945,-247.4762C76.839,-234.5329 74.93,-219.6086 73.4724,-208.2121\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"75.0695,-248.2865 79.8101,-257.7616 82.013,-247.3983 75.0695,-248.2865\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"81.6429\" y=\"-228.8\">3</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"node\" id=\"node17\">\n",
       "<title>lev('dig', 'dog'){}</title>\n",
       "<ellipse cx=\"356.1429\" cy=\"-448.9206\" fill=\"none\" rx=\"86.5824\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"356.1429\" y=\"-447.0995\">lev('dig', 'dog') ↦ 1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge28\">\n",
       "<title>lev('dig', 'dog'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M343.5719,-420.6897C327.6219,-384.8703 300.5788,-324.1391 287.1718,-294.0308\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"340.4907,-422.3744 347.756,-430.0859 346.8854,-419.5269 340.4907,-422.3744\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"329.6429\" y=\"-357.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;dog&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge36\">\n",
       "<title>lev('dig', 'dog'){}-&gt;lev('ig', 'dog'){}</title>\n",
       "<path d=\"M326.2229,-424.2088C313.8092,-414.9284 298.8802,-404.9544 284.1429,-398 276.0872,-394.1986 232.1531,-382.4923 197.1514,-373.4498\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"324.3196,-427.1602 334.3818,-430.4773 328.5843,-421.6094 324.3196,-427.1602\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"311.6429\" y=\"-400.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"node\" id=\"node18\">\n",
       "<title>lev('dig', 'og'){}</title>\n",
       "<ellipse cx=\"537.1429\" cy=\"-362\" fill=\"none\" rx=\"57.9805\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"537.1429\" y=\"-357.8\">lev('dig', 'og')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;dog&#39;){}&#45;&gt;lev(&#39;dig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge35\">\n",
       "<title>lev('dig', 'dog'){}-&gt;lev('dig', 'og'){}</title>\n",
       "<path d=\"M401.6111,-427.0857C434.032,-411.5164 476.8005,-390.9779 505.548,-377.1726\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"399.8352,-424.0558 392.3359,-431.5399 402.8655,-430.3659 399.8352,-424.0558\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"461.6429\" y=\"-400.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;og&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge34\">\n",
       "<title>lev('dig', 'og'){}-&gt;lev('ig', 'og'){}</title>\n",
       "<path d=\"M483.8747,-347.2926C479.5721,-346.1595 475.2878,-345.0493 471.1429,-344 437.0728,-335.3749 427.4923,-337.0896 394.1429,-326 379.4122,-321.1016 376.3749,-318.1997 362.1429,-312 345.7271,-304.849 327.4725,-296.928 312.272,-290.3407\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"483.3261,-350.7684 493.8901,-349.9604 485.128,-344.0043 483.3261,-350.7684\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"397.6429\" y=\"-314.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge29\">\n",
       "<title>lev('dig', 'og'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M528.581,-334.1876C519.6678,-306.3292 504.7124,-262.4693 488.1429,-226 485.3629,-219.8812 481.9279,-213.4021 478.6938,-207.6523\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"525.3414,-335.5518 531.692,-344.0324 532.0161,-333.4425 525.3414,-335.5518\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"517.6429\" y=\"-271.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"node\" id=\"node19\">\n",
       "<title>lev('dig', 'g'){}</title>\n",
       "<ellipse cx=\"615.1429\" cy=\"-276\" fill=\"none\" rx=\"53.1367\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"615.1429\" y=\"-271.8\">lev('dig', 'g')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;og&#39;){}&#45;&gt;lev(&#39;dig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge33\">\n",
       "<title>lev('dig', 'og'){}-&gt;lev('dig', 'g'){}</title>\n",
       "<path d=\"M559.6555,-337.1784C572.378,-323.1511 587.9695,-305.9605 599.3819,-293.3775\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"557.053,-334.838 552.9274,-344.5966 562.2381,-339.5408 557.053,-334.838\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"583.6429\" y=\"-314.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;g&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge32\">\n",
       "<title>lev('dig', 'g'){}-&gt;lev('ig', 'g'){}</title>\n",
       "<path d=\"M588.2025,-252.4788C577.1681,-243.5177 563.9892,-233.6347 551.1429,-226 536.0204,-217.0126 518.2434,-208.9985 503.0291,-202.8264\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"586.2507,-255.4073 596.1814,-259.0993 590.7206,-250.0202 586.2507,-255.4073\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"574.6429\" y=\"-228.8\">1</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;ig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge30\">\n",
       "<title>lev('dig', 'g'){}-&gt;lev('ig', ''){}</title>\n",
       "<path d=\"M605.603,-248.1532C596.0956,-220.5989 580.9602,-177.2625 567.1429,-140 564.9513,-134.0896 562.4816,-127.6659 560.2335,-121.9028\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"602.3923,-249.5793 608.9568,-257.8954 609.0111,-247.3007 602.3923,-249.5793\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"594.6429\" y=\"-185.8\">2</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"node\" id=\"node20\">\n",
       "<title>lev('dig', ''){}</title>\n",
       "<ellipse cx=\"670.1429\" cy=\"-190\" fill=\"none\" rx=\"48.7928\" ry=\"18\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"670.1429\" y=\"-185.8\">lev('dig', '')</text>\n",
       "</g>\n",
       "<!-- lev(&#39;dig&#39;, &#39;g&#39;){}&#45;&gt;lev(&#39;dig&#39;, &#39;&#39;){} -->\n",
       "<g class=\"edge\" id=\"edge31\">\n",
       "<title>lev('dig', 'g'){}-&gt;lev('dig', ''){}</title>\n",
       "<path d=\"M631.9605,-249.7033C640.6488,-236.118 651.0215,-219.8988 658.7615,-207.7964\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"628.9782,-247.8705 626.5389,-258.1807 634.8753,-251.642 628.9782,-247.8705\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"648.6429\" y=\"-228.8\">3</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph -w10 -r lev(\"big\", \"dog\"); lev(\"dig\", \"dog\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By default, `%callgraph` clears the cache of any function that has been decorated via `lru_cache`. The `--no-clear` options disables this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"194pt\" viewBox=\"0.00 0.00 470.20 193.52\" width=\"470pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 189.5238)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-189.5238 466.2038,-189.5238 466.2038,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- nchoosek(2, 0){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>nchoosek(2, 0){}</title>\n",
       "<ellipse cx=\"87.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"87.1019\" y=\"-90.9408\">nchoosek(2, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){} -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>nchoosek(3, 1){}</title>\n",
       "<ellipse cx=\"183.1019\" cy=\"-166.6032\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.1019\" y=\"-164.7821\">nchoosek(3, 1) ↦ 3</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 0){} -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 0){}</title>\n",
       "<path d=\"M159.3715,-148.3503C147.1406,-138.9425 132.0567,-127.3402 118.8387,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"120.9523,-114.3834 110.8919,-111.0607 116.6845,-119.9319 120.9523,-114.3834\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){} -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>nchoosek(2, 1){}</title>\n",
       "<ellipse cx=\"279.1019\" cy=\"-92.7619\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"279.1019\" y=\"-90.9408\">nchoosek(2, 1) ↦ 2</text>\n",
       "</g>\n",
       "<!-- nchoosek(3, 1){}&#45;&gt;nchoosek(2, 1){} -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>nchoosek(3, 1){}-&gt;nchoosek(2, 1){}</title>\n",
       "<path d=\"M206.8322,-148.3503C219.0631,-138.9425 234.1471,-127.3402 247.3651,-117.1732\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"249.5193,-119.9319 255.3118,-111.0607 245.2515,-114.3834 249.5193,-119.9319\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 0){} -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>nchoosek(1, 0){}</title>\n",
       "<ellipse cx=\"183.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.1019\" y=\"-17.0995\">nchoosek(1, 0) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 0){} -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 0){}</title>\n",
       "<path d=\"M255.3715,-74.509C243.1406,-65.1012 228.0567,-53.499 214.8387,-43.332\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"216.9523,-40.5421 206.8919,-37.2195 212.6845,-46.0906 216.9523,-40.5421\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- nchoosek(1, 1){} -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>nchoosek(1, 1){}</title>\n",
       "<ellipse cx=\"375.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"375.1019\" y=\"-17.0995\">nchoosek(1, 1) ↦ 1</text>\n",
       "</g>\n",
       "<!-- nchoosek(2, 1){}&#45;&gt;nchoosek(1, 1){} -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>nchoosek(2, 1){}-&gt;nchoosek(1, 1){}</title>\n",
       "<path d=\"M302.8322,-74.509C315.0631,-65.1012 330.1471,-53.499 343.3651,-43.332\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"345.5193,-46.0906 351.3118,-37.2195 341.2515,-40.5421 345.5193,-46.0906\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph nchoosek(3, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"46pt\" viewBox=\"0.00 0.00 182.20 45.84\" width=\"182pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 41.8413)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-41.8413 178.2038,-41.8413 178.2038,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- nchoosek(3, 1){} -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>nchoosek(3, 1){}</title>\n",
       "<ellipse cx=\"87.1019\" cy=\"-18.9206\" fill=\"none\" rx=\"87.2039\" ry=\"18.8416\" stroke=\"#000000\" stroke-width=\"3\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"87.1019\" y=\"-17.0995\">nchoosek(3, 1) ↦ 3</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%callgraph --no-clear nchoosek(3, 1)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda env:callgraph]",
   "language": "python",
   "name": "conda-env-callgraph-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  },
  "toc": {
   "nav_menu": {
    "height": "48px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 4,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
